package com.example.demotest.util;

public class ResponseMessage<T> {
    private int code;
    private String message;
    private T data;

    // 快速构建成功响应（带数据）
    public static <T> ResponseMessage<T> success(T data) {
        ResponseMessage<T> response = new ResponseMessage<>();
        response.code = 200;
        response.message = "成功";
        response.data = data;
        return response;
    }

    // 快速构建成功响应（无数据）
    public static <T> ResponseMessage<T> success() {
        return success(null);
    }

    // 快速构建错误响应
    public static <T> ResponseMessage<T> error(int code, String message) {
        ResponseMessage<T> response = new ResponseMessage<>();
        response.code = code;
        response.message = message;
        return response;
    }

    // Getter 和 Setter（根据需求添加）
    public int getCode() { return code; }
    public String getMessage() { return message; }
    public T getData() { return data; }
}